import { Button, Row, Col} from 'antd';
import {WeaDialog ,WeaNewScroll ,WeaLocaleProvider ,WeaBrowser ,WeaSelectGroup ,WeaRightMenu} from 'ecCom';
import {observer} from "mobx-react";
import _mapValues from 'lodash/mapValues'
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;

@observer
class ProjectFieldDetailLogDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {hrmid:'',date:[]};
    }

    shouldComponentUpdate(nextProps,nextState){
        return true;
    }
 
    render() {
        const {title,tableStore,store} = this.props;
        const {fieldDetailLogVisible} = store;
        const selectLinkageDatas = {
            "6": {
              conditionType: "RANGEPICKER",
              domkey: ["start", "end"]
            }
          };
        const options = [
        { key: "0", showname: getLabel(332,"全部") },
        { key: "1", showname: getLabel(15537,"今天") },
        { key: "2", showname: getLabel(15539,"本周") },
        { key: "3", showname: getLabel(15541,"本月") },
        { key: "4", showname: getLabel(21904,"本季") },
        { key: "5", showname: getLabel(15384,"本年") },
        { key: "6", showname: getLabel(32530,"指定日期范围") }
        ];
        const menu = [
            {
                key: '1',
                icon: <i className='icon-coms-search' />,
                content: getLabel(388113,'搜索'),
                onClick: () =>{
                    store.getPrjFieldDetaiLogList({prjid:store.prjid,fieldname:store.field,...this.state});
                }
            },
            {
                key: '2',
                icon: <i className='icon-coms-go-back' />,
                content: getLabel(309,"关闭"),
                onClick: () =>{
                    store.setFieldDetailLogVisible(false)
                }
            }
          ];
        return (
            <div>
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@ebzzs6`}
                title={title || getLabel(83,"日志")}
                visible={fieldDetailLogVisible}
                buttons={this.getButtons()}
                icon="icon-coms-ModelingEngine"
                iconBgcolor="#217346"
                onCancel={()=>{store.setFieldDetailLogVisible(false)}}
                style={{width:'700px', height:'400px'}}
            >
                <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@j4cr71`} datas={menu} >
                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@yzub0l`}>
                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@vce74f`} span={3} style={{textAlign:'center',marginTop:16}}>{getLabel(99,'操作者')}</Col>
                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@l9n2ui`} span={6} style={{marginTop:8,marginBottom:8}}>
                        <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@ml51kw`}
                        type={1}
                        textDecoration={true}
                        inputStyle={{ width: 200 }}
                        onChange={(ids, names, datas) =>{
                            this.setState({hrmid:ids});
                        }
                        }
                        />
                        </Col>
                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@lkx9jh`} span={1}></Col>
                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@vrl2zu`} span={3} style={{textAlign:'center',marginTop:16}}>{getLabel(22823,'日期')}</Col>
                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@wsgtg7`} span={11} style={{marginTop:8,marginBottom:8}}>
                        <WeaSelectGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSelectGroup@jaiswi`}
                        isMobx
                        value={0}
                        options={options}
                        selectLinkageDatas={selectLinkageDatas}
                        onChange={(value, rightKey) => {
                            this.setState({date:value});
                        }}
                        />
                        </Col>
                    </Row>
                    <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@5f2oua`} height={"calc(100% - 45px)"}>
                        <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@yfxb7q`} 
                            comsWeaTableStore={tableStore}
                            hasOrder={true}
                            needScroll={false}
                        />
                    </WeaNewScroll>
                </WeaRightMenu>
            </WeaDialog>
        </div>)
    }

    getButtons(){
        const {store} = this.props;
        let btnArr = []; 
        btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@33vs7m@close`}  type="primary" onClick={()=>store.setFieldDetailLogVisible(false)}>{getLabel(309,"关闭")}</Button>)  
        return btnArr;
    }
   
}

export default ProjectFieldDetailLogDialog;